﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QL_KhachSan.App_Code.OBJ;
using System.Data;
using System.Data.SqlClient;

namespace QL_KhachSan.App_Code.DAL
{
    class DAL_Nguoidung
    {
        Nguoidung user;
        db_Connection dbcon;
        public DAL_Nguoidung() {
            user = new Nguoidung();
            dbcon = new db_Connection();
        }
        public Nguoidung select_user(string query, SqlParameter[] p) {
            DataTable dt = new DataTable();
            dt = dbcon.proc_select_para(query, p);
            if (dt.Rows.Count == 1)
            {
                user._name = dt.Rows[0][0].ToString();
                user._pass = dt.Rows[0][1].ToString();
            }
            else 
                user = null;
            return user;
        }
        public void add_user(SqlParameter[] p)
        {
            dbcon.exe_proc_para("add_nguoidung", p);
        }
        public void delete_user(SqlParameter[] p)
        {
            dbcon.exe_proc_para("delete_nguoidung", p);
        }
        public void edit_user(SqlParameter[] p)
        {
            dbcon.exe_proc_para("edit_nguoidung", p);
        }
    }
}
